﻿#include "graph.h"
#define NUMOFNODE 10
void printTC(bool** TC, int n);
int main()
{
	Graph map(NUMOFNODE);
//	map.addEdge(0, 2);
	map.addEdge(0, 4);
	map.addEdge(4, 3);
	map.addEdge(3, 1);
	map.addEdge(1, 2);
	map.addEdge(1, 6);
	map.addEdge(4, 2);
	map.addEdge(2, 7);
	map.addEdge(5, 8);


	int* path;
	cout << "请输入theSource、theDestination:" << endl;
	int S, D;
	cin >> S;
	cin >> D;
	path = map.findPath2(S, D);
	if(path[0] == 0){
		cout << "无法找到此路径" << endl;
		return 0;
	}
	for (int i = 1; path[i] != D; i++)
		cout << path[i] << " -> ";
	cout << D << endl;
	cout << "此最短路径长度为" << path[0] << endl;
	

	bool** TC;
	TC = map.undirectedTC();
	printTC(TC, NUMOFNODE);
	return 0;
}
void printTC(bool** TC, int n) {
	cout << "传递闭包TC：" << endl;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (TC[i][j] == true)
				cout << "1 ";
			else
				cout << "0 ";
		}
		cout << endl;
	}
}
